package com.gjs.management.service.Impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gjs.management.mapper.SysRoleMapper;
import com.gjs.management.pojo.dto.role.SysRoleQueryDTO;
import com.gjs.management.pojo.entity.SysRole;
import com.gjs.management.service.ISysRoleService;
import org.springframework.stereotype.Service;

@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
    @Override
    public Wrapper<SysRole> buildWrapper(SysRoleQueryDTO queryDTO){
        LambdaQueryWrapper<SysRole> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(queryDTO.getId() != null && queryDTO.getId() > 0,SysRole::getId,queryDTO.getId());
        wrapper.like(!StrUtil.isEmpty(queryDTO.getRoleName()),SysRole::getRoleName,queryDTO.getRoleName());

        return wrapper;
    }
}
